package com.pwl.shiro.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@RequestMapping(path = "/user")
public class LoginController {

    @GetMapping(path ="/login")
    public String login(){
        return "login";
    }

    @GetMapping(path = "/main")
    public String index(){
//        用户登录成功后跳转的页面
        return "index";
    }

    @PostMapping(path = "/login")
    public String login(Model model){
//        用户登录失败，才会进入post[user/login]
        model.addAttribute("msg","用户登录失败");
        return "login";
    }
}

